<template>
  <div>
    <el-card shadow="hover" class="card1">
      <template slot="header">
        <div style="display: flex; justify-content: space-between">
          <div style="display: flex">
            <img style="width: 20px" src="./select.svg" />
            <span
              style="
                color: #666;
                margin-left: 10px;
                display: inline-table;
                width: 120px;
                line-height: 30px;
                font-size: 14px;
              "
              >{{title}}</span
            >
          </div>
        </div>
      </template>
      <div>
        <custom-form
          @searchFn="searchFn"
          labelWidth="140px"
          :list="list"
          :col="3"
          :gutter="10"
          labelPosition="left"
        >
          <template
            :slot="item.prop"
            slot-scope="scope"
            v-for="(item, i) in list"
          >
            <div :key="i">
              <slot :name="item.prop" :scope="scope">
                <el-form-item
                  :prop="scope.column.prop"
                  :rules="scope.column.rules"
                >
                  <div
                    slot="label"
                    style="background: #f4f4f4; text-indent: 10px"
                  >
                    {{ scope.column.label }}
                  </div>
                  <el-input
                    v-if="item.type === 'input'"
                    clearable
                    :placeholder="scope.column.placeholder || '请输入'"
                    v-model="scope.data[scope.column.prop]"
                  />
                  <el-date-picker
                    v-else-if="item.type === 'date'"
                    :type="scope.column.type"
                    :placeholder="scope.column.placeholder || '请选择日期'"
                    style="width: 100%"
                    v-model="scope.data[scope.column.prop]"
                  />
                  <el-radio-group
                    v-else-if="item.type === 'radio'"
                    v-model="scope.data[scope.column.prop]"
                  >
                    {{ scope }} -->
                    <el-radio
                      v-for="(radioItem, i) in scope.column.radioList"
                      :key="i"
                      :label="radioItem.key"
                      >{{ radioItem.value }}</el-radio
                    >
                    -->
                  </el-radio-group>
                  <el-select
                    v-else-if="item.type === 'select'"
                    style="width: 100%"
                    :placeholder="scope.column.placeholder || '请选择'"
                    clearable
                    v-model="scope.data[scope.column.prop]"
                  >
                    <el-option
                      v-for="(option, i) in scope.column.optionList"
                      :key="option.key + '_' + i"
                      :label="option.value"
                      :value="option.key"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </slot>
            </div>
          </template>
          <!-- <template #name="scope">
            <el-form-item
              :label="scope.column.label"
              :prop="scope.column.prop"
              :rules="scope.column.rules"
            >
              <el-input v-model="scope.data[scope.column.prop]"></el-input>
            </el-form-item>
          </template> -->
        </custom-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "highSearch",
  props: {
    list: {
      type: Array,
      required: true,
    },
    title: {
      type: String,
      default: '筛选查询'
    }
  },
  methods: {
    searchFn(params) {
      this.$emit("searchFn", params);
    },
  },
};
</script>

<style lang="less" scoped>
:deep(.el-card__header) {
  padding: 5px 20px;
  background-color: #fafafa;
  > span {
    color: #666;
    font-weight: 400;
    font-size: 12px;
  }
}
.select {
  font-size: 0;
  > span {
    font-size: 12px;
    display: inline-table;
    width: 70px;
    margin-left: 10px;
    text-align: center;
    background-color: #fff;
    height: 30px;
    border: 1px solid #cccccc;
    cursor: pointer;
    line-height: 30px;
  }
  > span:hover {
    background: #f3f3f3;
  }
}
:deep(.el-form-item) {
  margin-bottom: 10px;
}
</style>
